<%--
  Created by IntelliJ IDEA.
  User: dell
  Date: 2019/1/17
  Time: 14:16
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>
<head>
    <base href="<%=basePath %>">

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>APP 管理系统</title>
    <link rel="stylesheet" href="statics/layui/css/layui.css">
    <link rel="stylesheet" href="statics/css/newCSS.css">
</head>


<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo">APP管理系统
            <img src="statics/img/feature_thumb_1.jpg" class="layui-nav-img">
        </div>

        <!-- 头部区域（可配合layui已有的水平导航） -->
        <ul class="layui-nav layui-layout-left">
            <%--<li class="layui-nav-item"><a href="">App用户管理</a></li>--%>
            <%--<li class="layui-nav-item"><a href="">App应用管理</a></li>--%>

            <%--下拉列表--%>
            <%--<li class="layui-nav-item">--%>
                <%--<a href="javascript:;">其它系统</a>--%>
                <%--<dl class="layui-nav-child">--%>
                    <%--<dd><a href="">邮件管理</a></dd>--%>
                    <%--<dd><a href="">消息管理</a></dd>--%>
                    <%--<dd><a href="">授权管理</a></dd>--%>
                <%--</dl>--%>
            <%--</li>--%>
        </ul>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a href="javascript:;">
                    <img src="statics/img/feature_thumb_1.jpg" class="layui-nav-img">
                    ${User.devName}
                </a>
                <dl class="layui-nav-child">
                    <dd><a href="">基本资料</a></dd>
                    <dd><a href="">安全设置</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item"><a href="User/login">登录</a></li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree"  lay-filter="test">
                <li class="layui-nav-item layui-nav-itemed">
                    <a class="" href="javascript:;">App账户管理</a>
                    <dl class="layui-nav-child">
                        <dd><a href="javascript:;">列表一</a></dd>
                        <dd><a href="javascript:;">列表二</a></dd>
                        <dd><a href="javascript:;">列表三</a></dd>
                        <dd><a href="">超链接</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a href="javascript:;">APP应用管理</a>
                    <dl class="layui-nav-child">
                        <dd><a href="">APP维护</a></dd>
                        <dd><a href="javascript:;">列表二</a></dd>
                        <dd><a href="">超链接</a></dd>
                    </dl>
                </li>
             <li class="layui-nav-item">
                 <c:if test="${User.devName==null}">
                     <a class="layui-btn layui-btn-disabled" style="color: red">注销</a>
                 </c:if>

                 <c:if test="${User.devName!=null}">

                 <a class="layui-btn layui-btn-warm" id="ZX" href="User/zx">注销</a>
                </c:if>
             </li>
            </ul>
        </div>
    </div>

    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div style="padding: 15px;">



            <div class="layui-card">

                <div class="layui-card-body">
                    <h3>欢迎您：${User.devName}|角色：${User.devCode}</h3><br>

                </div>

                <div class="layui-card" id="mokuai1">
                    <div class="layui-card-header">APP信息管理维护</div>
                    <div class="layui-card-body">


                            <div class="layui-form-item">
                                <label class="layui-form-label">软件名称</label>
                                <div class="layui-input-inline">
                                    <input type="tel" name="phone" lay-verify="required|phone" autocomplete="off" class="layui-input" id="softwareName">

                                </div>





                                <div class="layui-inline">
                                    <label class="layui-form-label">APP状态</label>
                                    <div class="layui-input-inline">
                                        <select id="statusName">
                                            <option value="">请选择</option>

                                                <option value="1">待审核</option>
                                                <option value="4">已上架</option>
                                                <option value="2">审核通过</option>
                                                <option value="3">审核未通过</option>
                                                <option value="5">已下架</option>

                                        </select>
                                    </div>
                                </div>

                                <div class="layui-inline">
                                    <label class="layui-form-label">所属平台</label>
                                    <div class="layui-input-inline">
                                        <select id="flatformName">
                                            <option value="">请选择</option>

                                            <option value="1">手机</option>
                                            <option value="2">平板</option>
                                            <option value="3">通用</option>


                                        </select>
                                    </div>
                                </div>




                            </div>


                        <div class="layui-inline">
                            <label class="layui-form-label">一级分类</label>
                            <div class="layui-input-inline">
                                <select id="categoryLevel1">
                                    <option value="" id="categoryLevel10">请选择</option>

                                </select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">二级分类</label>
                            <div class="layui-input-inline">
                                <select name="quiz">
                                    <!--用C if判断是否选择一级分类-->
                                    <option value="">请选择问题</option>
                                    <optgroup label="城市记忆">
                                        <option value="你工作的第一个城市">你工作的第一个城市</option>
                                    </optgroup>
                                    <optgroup label="学生时代">
                                        <option value="你的工号">你的工号</option>
                                        <option value="你最喜欢的老师">你最喜欢的老师</option>
                                    </optgroup>
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">三级分类</label>
                            <div class="layui-input-inline">
                                <select name="quiz">
                                    <!--用C if判断是否选择二级分类-->
                                    <option value="">请选择问题</option>
                                    <optgroup label="城市记忆">
                                        <option value="你工作的第一个城市">你工作的第一个城市</option>
                                    </optgroup>
                                    <optgroup label="学生时代">
                                        <option value="你的工号">你的工号</option>
                                        <option value="你最喜欢的老师">你最喜欢的老师</option>
                                    </optgroup>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit="" lay-filter="demo1" onclick="Load()">立即提交</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </div>

                <div class="layui-card" id="mokuai2">
                    <div class="layui-card-header"><a href="" class="layui-btn layui-btn-normal">新增App基础信息</a></div>


                    <div class="layui-form">
                        <table class="layui-table" id="book">
                            <colgroup>
                                <col width="150">
                                <col width="150">
                                <col width="200">
                                <col>
                            </colgroup>
                            <thead id="indexs">
                            <tr style="background-color:rgb(219,241,212);" >
                                <th>编号</th>
                                <th>软件名称</th>

                                <th>APK名称</th>

                                <th>软件大小(单位:M)</th>

                                <th>所属平台</th>

                                <th>所属分类(一级分类、二级分类、三级分类)</th>

                                <th>状态</th>

                                <th>下载次数</th>

                                <th>最新版本号</th>

                                <th>操作</th>

                            </tr>
                            </thead>
                        </table>
                    </div>




                        <div class="pages">

                            <a href="javascript:void(0)" onclick="pages(0)">首頁</a>
                            <a href="javascript:void(0)" onclick="pages(-1)">上一页</a>

                            &nbsp;&nbsp;  &nbsp;&nbsp;

                            <a href="javascript:void(0)" onclick="pages(1)">下一页</a>
                            &nbsp;&nbsp;
                            <a href="javascript:void(0)" onclick="pages(2)">末頁</a>

                            &nbsp;&nbsp;  &nbsp;&nbsp;
                            <span id="page"></span>
                        </div>

                    </div>





            </div>
        </div>
    </div>

    <div class="layui-footer">
        <!-- 底部固定区域 -->
        © layui.com - 底部固定区域
    </div>
</div>
<script src="statics/js/jquery-1.12.4.js"></script>
<script src="statics/layui/layui.js"></script>
<script>
    $(function () {
        categoryLevel1();
        Load();

    });
    //JavaScript代码区域
    layui.use('element', function(){
        var element = layui.element;

    });

    var pageIndex=1;
    var totalPageCount=0;

    function Load() {
        var softwareName=$("#softwareName").val();
        var statusName=$("#statusName").val();
        var flatformName=$("#flatformName").val();

                          $.ajax({
                        url:"info/infoall",
                        type:"POST",
                        data:{
                            softwareName:softwareName,
                            statusName:statusName,
                            flatformName:flatformName,
                            pageIndex:pageIndex
                        },
                        dataType:"json",
                        success:function (data) {

                            $("#indexs").siblings().remove();
                            totalPageCount=data.pages.totalPageCount;

                            var $html;
                            $("#page").html("第"+pageIndex+"页/共"+totalPageCount+"页");

                            for(var i=0;i<data.list.length;i++){
                                $html = "<tr>" +
                                    " <td >"+data.list[i].id+"</td>"
                                    +  "<td>" + data.list[i].softwareName + "</td>"

                                    + "<td>" + data.list[i].aPKName + "</td>" + "<td>"

                                    + data.list[i].softwareSize + "</td>" + "<td>"

                                    + data.list[i].flatformName + "</td>" + "<td>"

                                    +data.list[i].categoryLevel1Name + ">"

                                    + data.list[i].categoryLevel2Name + ">"

                                    +data.list[i].categoryLevel3Name + "</td>" + "<td>"

                                    + data.list[i].statusName + "</td>" + "<td>"

                                    + data.list[i].downloads + "</td>" + "<td>"

                                    + data.list[i].versionNo + "</td>"

                                    + "<td>" +
                                    "<span class='layui-badge layui-bg-red' onclick='update("+data.list[i].id+")'>--下架--</span>"
                                    + "<span class='layui-badge layui-bg-orange'>--修改--</span>"

                                    + "<span class='layui-badge layui-bg-green' onclick='delect("+data.list[i].id+")'>--删除--</span>"





                                    + " </td></tr>";
                    $("#book").append($html);
                }

            }


        })

    }
    function  update(id) {

        $.ajax({
            url: "info/update",
            type: "POST",
            data: {id: id},
            dataType: "text",
            success:function (data) {
                if(data>0){

                    Load();
                    alert("下架成功")
                }else {
                    alert("下架失败")
                }
            }
        })
    }

    function  delect(idd) {

        $.ajax({
            url: "info/delect",
            type: "POST",
            data: {idd: idd},
            dataType: "text",
            success:function (data) {
                if(data>0){

                    Load();
                    alert("删除成功")
                }else {
                    alert("删除失败")
                }
            }
        })
    }

    function  categoryLevel1() {

        $.ajax({
            url: "info/categoryLevel1",
            type: "POST",
            data: {},
            dataType: "json",
            success:function (data) {

                $("#categoryLevel10").siblings().remove();
                var $html;

                for ( var i = 0; i < data.length; i++) {

                    $html = "'<option value='"+data[i].id+"'>"+data[i].categoryName+"</option>'";

                    $("#categoryLevel1").append($html);

                }

            }
        })
    }
    function pages(CurrentPageNo){
        if(CurrentPageNo==2){
            pageIndex=totalPageCount;
        }
        else if(CurrentPageNo==0){
            pageIndex=1;
        }
        else if(CurrentPageNo==-1){
            pageIndex=pageIndex-1;
        }else if(pageIndex<1){
            pageIndex=1;
        }else if(pageIndex>totalPageCount){
            pageIndex=totalPageCount;
        }
        else{
            pageIndex=pageIndex+1;
        }
        if(pageIndex>=1&&pageIndex<=totalPageCount){
            Load();
        }
    };
</script>
</body>

</html>
